#include "btform.h"
#include "ui_btform.h"
#include<QDebug>
BtForm::BtForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::BtForm)
{
    ui->setupUi(this);
    ui->linebox->hide();
    line1Animation=new QPropertyAnimation(ui->line1,"geometry",this);
    line2Animation=new QPropertyAnimation(ui->line2,"geometry",this);
    line3Animation=new QPropertyAnimation(ui->line3,"geometry",this);
    line4Animation=new QPropertyAnimation(ui->line4,"geometry",this);
    line1Animation->setDuration(1500);
    line1Animation->setLoopCount(-1);
    line1Animation->setKeyValueAt(0,QRect(1,70,6,0));
    line1Animation->setKeyValueAt(0.5,QRect(1,30,6,40));
    line1Animation->setKeyValueAt(1,QRect(1,70,6,0));
    line1Animation->start();
    line2Animation->setDuration(1600);
    line2Animation->setLoopCount(-1);
    line2Animation->setKeyValueAt(0,QRect(13,70,6,0));
    line2Animation->setKeyValueAt(0.55,QRect(13,30,6,40));
    line2Animation->setKeyValueAt(1,QRect(13,70,6,0));
    line2Animation->start();
    line3Animation->setDuration(1700);
    line3Animation->setLoopCount(-1);
    line3Animation->setKeyValueAt(0,QRect(25,70,6,0));
    line3Animation->setKeyValueAt(0.65,QRect(25,30,6,40));
    line3Animation->setKeyValueAt(1,QRect(25,70,6,0));
    line3Animation->start();
    line4Animation->setDuration(1800);
    line4Animation->setLoopCount(-1);
    line4Animation->setKeyValueAt(0,QRect(37,70,6,0));
    line4Animation->setKeyValueAt(0.7,QRect(37,30,6,40));
    line4Animation->setKeyValueAt(1,QRect(37,70,6,0));
    line4Animation->start();
}

BtForm::~BtForm()
{
    delete ui;
}



void BtForm::setIconAndText(const QString &icon, const QString &text,int id)
{
    //设置bodyleft图片和文本和id
   ui->bticon->setPixmap(QPixmap(icon));
   ui->bttext->setText(QString(text));
   PageId=id;
}

int BtForm::getPageId()
{
    return PageId;
}

void BtForm::clearbackground()
{
    ui->btstyle->setStyleSheet("#btstyle:hover{background-color:#D8D8D8;}");
}

void BtForm::showAnimation()
{
   ui->linebox->show();
}

void BtForm::mousePressEvent(QMouseEvent *event)
{
    (void)event;
   //鼠标按下时改变背景颜色，并切换bodyRight的页面
    ui->btstyle->setStyleSheet("#btstyle{background-color:rgb(30,206,154);}");
    emit btClick(PageId);
}
